<template>
    <div class="container">
        <div class="archive-detail">
            <div class="archive-header">
                <div class="header-info">
                    <h2>{{ currentArchive.title }}</h2>
                    <div class="header-meta">
                        <div class="meta-item">
                            <i class="fas fa-calendar-alt"></i>
                            {{ currentArchive.period }} {{ currentArchive.date }}
                        </div>
                        <div class="meta-item">
                            <i class="fas fa-users"></i>
                            培训人数: {{ currentArchive.participants }}人
                        </div>
                        <div class="meta-item">
                            <i class="fas fa-clock"></i>
                            培训周期: {{ currentArchive.duration }}
                        </div>
                    </div>
                </div>

                <div class="archive-stats">
                    <div class="stat-item">
                        <div class="stat-value">{{ currentArchive.attendance }}%</div>
                        <div class="stat-label">课程签到率</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value">{{ currentArchive.satisfaction }}%</div>
                        <div class="stat-label">考试签到率</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value">{{ currentArchive.passRate }}%</div>
                        <div class="stat-label">考试合格率</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value">{{ currentArchive.avgScore }}</div>
                        <div class="stat-label">考试平均分</div>
                    </div>
                </div>
            </div>

            <div class="archive-body">
                <div class="section">
                    <div class="section-header">
                        <div class="section-icon">
                            <el-icon><folder-opened /></el-icon>
                        </div>
                        <h3 class="section-title">培训计划与材料</h3>
                    </div>
                    <div class="section-content">
                        <div class="data-grid plan-materials-grid">
                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <school />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">教学课程</div>
                                </div>
                                <div class="card-content">
                                    <ul>
                                        <li style="white-space: pre-wrap; overflow-wrap: break-word;" v-for="(item, index) in currentArchive.planItems" :key="index">
                                            {{ index + 1  + "."}} 课程名称:{{ item.courseName }}；视频名称:{{item.name}}；培训讲师:{{item.teachName}}；视频时长:{{formatTime(item.time)}}。
                                        </li>
                                    </ul>
                                </div>
                            </div>

                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <document />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">教学材料</div>
                                </div>
                                <div class="card-content">
                                    <ul>
                                        <li style="white-space: pre-wrap; overflow-wrap: break-word;" v-for="(item, index) in currentArchive.materials" :key="index">
                                            {{ index + 1  + "."}} 课程名称:{{ item.courseName }}；课件名称:{{item.name}}。
                                        </li>
                                    </ul>
                                </div>
                            </div>

                            <!--<div class="data-card">-->
                                <!--<div class="card-header">-->
                                    <!--<div class="card-icon">-->
                                        <!--<el-icon>-->
                                            <!--<editPen />-->
                                        <!--</el-icon>-->
                                    <!--</div>-->
                                    <!--<div class="card-title">培训讲师团队</div>-->
                                <!--</div>-->
                                <!--<div class="card-content">-->
                                    <!--<ul>-->
                                        <!--<li v-for="(teacher, index) in currentArchive.teachers" :key="index">-->
                                            <!--{{ index != 3 ? index + 1 + "." : '' }} {{ teacher }}-->
                                        <!--</li>-->
                                    <!--</ul>-->
                                <!--</div>-->
                            <!--</div>-->

                            <!--<div class="data-card">-->
                                <!--<div class="card-header">-->
                                    <!--<div class="card-icon">-->
                                        <!--<el-icon>-->
                                            <!--<discount />-->
                                        <!--</el-icon>-->
                                    <!--</div>-->
                                    <!--<div class="card-title">培训负责人团队</div>-->
                                <!--</div>-->
                                <!--<div class="card-content">-->
                                    <!--<ul>-->
                                        <!--<li v-for="(manage, index) in currentArchive.manages" :key="index">-->
                                            <!--{{ index != 3 ? index + 1 + "." : '' }} {{ manage }}-->
                                        <!--</li>-->
                                    <!--</ul>-->
                                <!--</div>-->
                            <!--</div>-->
                        </div>
                    </div>
                </div>

                <div class="section">
                    <div class="section-header">
                        <div class="section-icon">
                            <el-icon><folder-opened /></el-icon>
                        </div>
                        <h3 class="section-title">课堂考试记录</h3>
                    </div>
                    <div class="section-content">
                        <div class="data-grid plan-materials-grid">
                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <document />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">班主任日志</div>
                                </div>
                                <div class="card-content">
                                    <ul>
                                        <li style="white-space: pre-wrap; overflow-wrap: break-word;" v-for="(periodLog, index) in currentArchive.certificates?.periodLog" :key="index">
                                            {{ index + 1 + "." }}{{ periodLog }}
                                        </li>
                                    </ul>
                                </div>
                            </div>

                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <editPen />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">办班总结</div>
                                </div>
                                <div class="card-content">
                                    <ul>
                                        <li style="white-space: pre-wrap; overflow-wrap: break-word;" v-for="(classSum, index) in currentArchive.certificates?.classSum"
                                            :key="index">
                                            {{ index + 1 + "." }}{{ classSum }}
                                        </li>
                                    </ul>
                                </div>
                            </div>

                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <discount />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">执行情况</div>
                                </div>
                                <div class="card-content">
                                    <ul>
                                        <li style="white-space: pre-wrap; overflow-wrap: break-word;" v-for="(trainSitu, index) in currentArchive.certificates?.trainSitu"
                                            :key="index">
                                            {{ index + 1 + "." }}{{ trainSitu }}
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="section">
                    <div class="section-header">
                        <div class="section-icon">
                            <el-icon><folder-opened /></el-icon>
                        </div>
                        <h3 class="section-title">学员学习情况</h3>
                    </div>
                    <div class="section-content">
                        <div class="data-card">
                            <div class="card-header">
                                <div class="card-icon">
                                    <el-icon>
                                        <Promotion />
                                    </el-icon>
                                </div>
                                <div class="card-title">课程签到率</div>
                            </div>
                            <div class="card-content">
                                <div class="chart-grid">
                                    <div class="chart-container">
                                        <canvas id="courseAttendanceChart"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="data-card">
                            <div class="card-header">
                                <div class="card-icon">
                                    <el-icon>
                                        <Promotion />
                                    </el-icon>
                                </div>
                                <div class="card-title">考试签到率</div>
                            </div>
                            <div class="card-content">
                                <div class="chart-grid">
                                    <div class="chart-container">
                                        <canvas id="examAttendanceChart"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="data-card">
                            <div class="card-header">
                                <div class="card-icon">
                                    <el-icon>
                                        <Promotion />
                                    </el-icon>
                                </div>
                                <div class="card-title">考试成绩分析</div>
                            </div>
                            <div class="card-content">
                                <div class="chart-grid">
                                    <div class="chart-container">
                                        <canvas id="scoreChart"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <h4 style="margin: 25px 0 15px; color: #4b5563;">学员成绩</h4>
                        <div class="participants-list">
                            <div class="participant-card" v-for="(student, index) in topStudents" :key="index">
                                <div class="card-header">
                                    <div class="avatar">{{ student.username.charAt(0) }}</div>
                                    <div class="participant-name">{{ student.username }}</div>
                                    <div class="meta-item">
                                        <span class="meta-label">课程:</span>
                                        <span class="meta-value">{{ student.courseName }}</span>
                                    </div>
                                    <div class="meta-item">
                                        <span class="meta-label">班级:</span>
                                        <span class="meta-value">{{ student.trainClassNum }}</span>
                                    </div>
                                    <div class="meta-item">
                                        <span class="meta-label">成绩:</span>
                                        <span class="meta-value">{{ student.exampaperGetScore }}</span>
                                    </div>
                                    <div class="score-badge" :class="student.isPass === 1 ? 'high-score' : 'low-score'">
                                        {{ student.isPass === 1 ? '及格' : '不及格' }}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="section">
                    <div class="section-header">
                        <div class="section-icon">
                            <el-icon><folder-opened /></el-icon>
                        </div>
                        <h3 class="section-title">学员反馈与评价</h3>
                    </div>
                    <div class="section-content">
                        <div class="data-grid">
                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <Notebook />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">课程反馈</div>
                                </div>
                                <div class="card-content">
                                    <div class="feedback-list">
                                        <div class="feedback-item"
                                            v-for="(courseFeedback, index) in currentArchive.courseFeedbacks"
                                            :key="index">
                                            <div class="feedback-header">
                                                <span>学员名称：{{ courseFeedback.name }} | 班级编号：{{ courseFeedback.department }} | 课程名称：{{
                                                    courseFeedback.courseName }}</span>
                                            </div>
                                            <div class="feedback-content" style="white-space: pre-wrap; overflow-wrap: break-word;">
                                                "{{ courseFeedback.comment }}"
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <Notebook />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">培训讲师评价</div>
                                </div>
                                <div class="card-content">
                                    <div class="feedback-list">
                                        <div class="feedback-item" v-for="(feedback, index) in currentArchive.feedbacks"
                                            :key="index">
                                            <div class="feedback-header">
                                                <span>学员名称：{{ feedback.name }} | 班级编号：{{ feedback.department }} | 培训讲师名称：{{
                                                    feedback.teachName }}</span>
                                            </div>
                                            <div class="feedback-content" style="white-space: pre-wrap; overflow-wrap: break-word;">
                                                "{{ feedback.comment }}"
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="section">
                    <div class="section-header">
                        <div class="section-icon">
                            <el-icon><folder-opened /></el-icon>
                        </div>
                        <h3 class="section-title">培训成果与总结</h3>
                    </div>
                    <div class="section-content">
                        <div class="data-grid">
                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <Cherry />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">培训心得</div>
                                </div>
                                <div class="card-content">
                                    <p>{{ currentArchive.xinde }}</p>
                                </div>
                            </div>

                            <div class="data-card">
                                <div class="card-header">
                                    <div class="card-icon">
                                        <el-icon>
                                            <Present />
                                        </el-icon>
                                    </div>
                                    <div class="card-title">改进措施</div>
                                </div>
                                <div class="card-content">
                                    <p>{{ currentArchive.cuoshi }}</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="archive-actions">
                    <button class="action-btn print-btn" @click="printPDF">
                        <i class="fas fa-print"></i> 打印本页
                    </button>
                </div>
            </div>
        </div>
        <footer>
            <p>© 2025 企业培训数据管理系统 | 深度分析每期培训成果</p>
        </footer>
    </div>
</template>
<script>
import Chart from 'chart.js/auto';
import { router } from '../router/index';

export default {
    data() {
        return {
            currentArchive: {},
            topStudents: [],
            // 图表图片
            courseAttendanceImage: null,
            examAttendanceImage: null,
            scoreChartImage: null,
            // 班级名称
            classNames: [],
            // 课程名称
            courseNames: [],
            // 各班课程签到率数据
            courseAttendanceData: [],
            // 各班考试签到率数据
            examAttendanceData: [],
            // 考试成绩分数区间人数{'90分以上', '80 - 89分', '70 - 79分', '60 - 69分', '60分以下'}
            scoreStatistic: [0, 0, 0, 0, 0],
        }
    },
    mounted() {
        this.load()
        this.renderCharts();

    },
    methods: {
        load() {
            if (Object.keys(this.$store.state.pdfData).length === 0) {
                router.push('/print/printList');
                return
            }
            this.currentArchive = this.$store.state.pdfData
            this.getclassSignRateData(this.currentArchive.courseSignRate, this.currentArchive.examSignRate);
            this.getScoreStatistic(this.currentArchive.topStudents);
            this.topStudents = this.currentArchive.topStudents.length > 0 ? this.currentArchive.topStudents.slice(0, 5) : [];
            console.log(this.currentArchive)
        },
        formatTime(seconds) {
            if (seconds == null || seconds === '' || isNaN(seconds)) return '00:00';
            seconds = parseInt(seconds);
            const hours = Math.floor(seconds / 3600);
            const minutes = Math.floor((seconds % 3600) / 60);
            const secs = seconds % 60;

            if (hours > 0) {
                return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
            } else {
                return `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
            }
        },
        // 处理组装图数据
        getclassSignRateData(classData, examData) {
            // 获取所有班级名称
            const classNames = Object.keys(classData);

            // 构建基于课程ID的唯一课程列表
            const uniqueCourses = [...new Map(
                Object.values(classData)
                    .flat()
                    .map(course => [course.courseId, course])
            ).values()];

            // 提取课程名称列表（按课程ID去重后）
            const courseNames = uniqueCourses.map(course => course.courseName);

            // 提取通用的数据处理逻辑
            const processAttendanceData = (dataSource) => {
                return classNames.map(className => {
                    const classCourses = dataSource[className] || [];
                    return courseNames.map(courseName => {
                        // 找到对应课程ID的课程
                        const courseId = uniqueCourses.find(c => c.courseName === courseName)?.courseId;
                        const course = classCourses.find(c => c.courseId === courseId);

                        if (!course || course.requiredSign === 0) {
                            return 0;
                        }
                        // 计算签到率，保留两位小数
                        const signRate = (course.actualSign / course.requiredSign) * 100;
                        return parseFloat(signRate.toFixed(2));
                    });
                });
            };

            this.courseAttendanceData = processAttendanceData(classData);
            this.examAttendanceData = processAttendanceData(examData);
            this.classNames = classNames;
            this.courseNames = courseNames;
        },
        // 处理饼图数据
        getScoreStatistic(topStudents) {
            const scoreRanges = [90, 80, 70, 60, 0];
            topStudents.forEach(student => {
                const score = student.exampaperGetScore;
                for (let i = 0; i < scoreRanges.length; i++) {
                    if (score >= scoreRanges[i]) {
                        this.scoreStatistic[i]++;
                        break;
                    }
                }
            });
        },

        renderCharts() {
            // 销毁现有图表
            const charts = ['courseAttendanceChart', 'examAttendanceChart', 'scoreChart'];
            charts.forEach(id => {
                const canvas = document.getElementById(id);
                if (canvas) {
                    const chartInstance = Chart.getChart(canvas);
                    if (chartInstance) chartInstance.destroy();
                }
            });

            // 修改模拟数据格式
            const classes = this.classNames;
            const courses = this.courseNames;
            const courseAttendance = this.courseAttendanceData; // 各班级课程签到率
            const examAttendance = this.examAttendanceData; // 各班级考试签到率

            // 动态生成颜色函数
            function generateColors(count) {
                const colors = [];
                const hueStep = 360 / count;

                for (let i = 0; i < count; i++) {
                    // 计算色相值（0-360）
                    const hue = Math.round(i * hueStep) % 360;
                    // 使用固定的饱和度和亮度，确保颜色清晰可见
                    const saturation = 70;
                    const lightness = 60;

                    // 创建HSL颜色
                    colors.push(`hsla(${hue}, ${saturation}%, ${lightness}%, 0.7)`);
                }

                return colors;
            }

            // 生成与课程数量匹配的颜色数组
            const courseColors = generateColors(courses.length);

            // 课程签到率图表
            const courseCtx = document.getElementById('courseAttendanceChart')?.getContext('2d');
            if (courseCtx) {
                new Chart(courseCtx, {
                    type: 'bar',
                    data: {
                        labels: classes,
                        datasets: courses.map((course, index) => ({
                            label: course,
                            data: courseAttendance.map(classData => classData[index]),
                            backgroundColor: courseColors[index],
                            borderColor: courseColors[index].replace('0.7', '1'),
                            borderWidth: 1
                        }))
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        scales: {
                            y: {
                                beginAtZero: false,
                                min: 0,
                                max: 100,
                                ticks: {
                                    callback: function (value) {
                                        return value + '%';
                                    }
                                }
                            }
                        },
                        plugins: {
                            legend: {
                                position: 'top'
                            }
                        }
                    }
                });
            }

            // 考试签到率图表
            const examCtx = document.getElementById('examAttendanceChart')?.getContext('2d');
            if (examCtx) {
                new Chart(examCtx, {
                    type: 'bar',
                    data: {
                        labels: classes,
                        datasets: courses.map((course, index) => ({
                            label: course,
                            data: examAttendance.map(classData => classData[index]),
                            backgroundColor: courseColors[index],
                            borderColor: courseColors[index].replace('0.7', '1'),
                            borderWidth: 1
                        }))
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        scales: {
                            y: {
                                beginAtZero: false,
                                min: 0,
                                max: 100,
                                ticks: {
                                    callback: function (value) {
                                        return value + '%';
                                    }
                                }
                            }
                        },
                        plugins: {
                            legend: {
                                position: 'top'
                            }
                        }
                    }
                });
            }

            // 成绩分布饼图（保持不变）
            const scoreCtx = document.getElementById('scoreChart')?.getContext('2d');
            if (scoreCtx) {
                new Chart(scoreCtx, {
                    type: 'pie',
                    data: {
                        labels: ['90分以上', '80 - 89分', '70 - 79分', '60 - 69分', '60分以下'],
                        datasets: [{
                            data: this.scoreStatistic,
                            backgroundColor: [
                                'rgba(16, 185, 129, 0.7)',
                                'rgba(101, 163, 13, 0.7)',
                                'rgba(234, 179, 8, 0.7)',
                                'rgba(249, 115, 22, 0.7)',
                                'rgba(239, 68, 68, 0.7)'
                            ],
                            borderWidth: 1
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: { position: 'right' }
                        }
                    }
                });
            }
        },
        async printPDF() {
            // 触发浏览器打印功能
            window.print();
        },

    }
}
</script>
<style scoped>
/* 打印专用样式 */
@media print {
    body * {
        visibility: hidden;
    }

    .archive-detail,
    .archive-detail * {
        visibility: visible;
    }

    .archive-detail {
        position: relative;
        /* 改为relative定位 */
        width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    .archive-actions {
        display: none !important;
    }

    footer {
        page-break-after: always;
    }

    /* 防止头部和身体分页 */
    .archive-header {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .archive-body {
        page-break-before: avoid;
        page-break-inside: avoid;
    }

    /* 新增图表打印优化样式 */
    .chart-container {
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    .data-card {
        page-break-inside: avoid;
    }

    .section {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    /* 调整图表布局 */
    .chart-grid {
        display: flex !important;
        flex-direction: column !important;
    }

    /* 确保图表容器有足够空间 */
    .section-content {
        width: 95% !important;
        margin: 0 auto !important;
    }

    /* 确保头部和身体在同一页 */
    @page {
        size: auto;
        margin: 10mm;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: #f0f5ff;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(90deg, #2563eb 0%, #1e40af 100%);
    color: white;
    padding: 25px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    font-size: 2.5rem;
    background: white;
    color: #2563eb;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.logo-text h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.logo-text p {
    font-size: 1rem;
    opacity: 0.9;
}

.controls {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #fff;
    color: #2563eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background: #f0f4f8;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

.filter-bar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.filter-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
}

.filter-group select,
.filter-group input {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    font-size: 1rem;
}

.archive-detail {
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 30px;
}

.archive-header {
    background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 25px;
    display: flex;
    flex-direction: column;
    /* 改为垂直布局 */
    gap: 15px;
}

.header-info {
    width: 100%;
}

.header-info h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.header-meta {
    display: flex;
    gap: 20px;
    font-size: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.archive-stats {
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 20px;
    border-radius: 10px;
    justify-content: space-around;
}

.stat-item {
    text-align: center;
    /* 居中 */
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 15px;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    height: 40px;
    width: 1px;
    background: rgba(255, 255, 255, 0.3);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.archive-body {
    padding: 30px;
}

.section {
    margin-bottom: 35px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.section-icon {
    width: 40px;
    height: 40px;
    background: #e0e7ff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    font-size: 1.2rem;
    margin-right: 15px;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #1f2937;
}

.section-content {
    padding: 0 20px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(1200px, 1fr));
    gap: 20px;
}

/* 控制信息隐藏 */
.plan-materials-grid .data-card .card-content li {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}


.data-card {
    margin-bottom: 10px;
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.data-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
    border-color: #c7d2fe;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.card-icon {
    width: 35px;
    height: 35px;
    background: #dbeafe;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-size: 1rem;
    margin-right: 12px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.card-content {
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.7;
}

.card-content ul {
    padding-left: 20px;
    margin-top: 10px;
}

.card-content li {
    margin-bottom: 8px;
}

.chart-container {
    height: 250px;
    margin-top: 20px;
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.participant-card {
    display: flex;
    flex-direction: column;
    padding: 15px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.participant-card:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.participant-card .card-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.participant-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1f2937;
}

.score-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.high-score {
    background: #dcfce7;
    color: #166534;
}

.low-score {
    background: #fee2e2;
    color: #b91c1c;
}

.participant-meta {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 15px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    text-align: center;
}

.meta-label {
    font-weight: 500;
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.meta-value {
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 500;
}

.high-score {
    background: #dcfce7;
    color: #166534;
}

.medium-score {
    background: #fef3c7;
    color: #92400e;
}

.low-score {
    background: #fee2e2;
    color: #b91c1c;
}

.feedback-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.feedback-item {
    background: #f9fafb;
    border-radius: 10px;
    padding: 15px;
    border-left: 4px solid #4f46e5;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #6b7280;
}

.feedback-content {
    color: #4b5563;
    line-height: 1.6;
    overflow: hidden;
    text-overflow: ellipsis;
    /*display: -webkit-box;*/
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.archive-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

.action-btn {
    padding: 12px 35px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.print-btn {
    background: #3b82f6;
    color: white;
    border: none;
}

.print-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.export-btn {
    background: #10b981;
    color: white;
    border: none;
}

.export-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

.archive-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.archive-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.archive-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.card-top {
    background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 20px;
}

.card-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    opacity: 0.9;
}

.card-body {
    padding: 20px;
}

.card-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.card-stat {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
}

.card-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.card-stat-label {
    font-size: 0.85rem;
    color: #6b7280;
}

.card-action {
    text-align: center;
}

.view-btn {
    display: inline-block;
    padding: 8px 20px;
    background: #4f46e5;
    color: white;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.view-btn:hover {
    background: #3730a3;
}

footer {
    text-align: center;
    padding: 30px 0;
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 40px;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 992px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .archive-stats {
        width: 100%;
        justify-content: center;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .archive-stats {
        flex-wrap: wrap;
    }

    .stat-item {
        width: 45%;
        margin-bottom: 15px;
    }

    .participant-meta {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-wrap: wrap;
    }
}


.chart-container {
    min-height: 250px;
    /* 确保图表有足够空间 */
}

/* 添加卡片悬停效果 */
.data-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* 增强标题视觉 */
.section-title {
    position: relative;
    padding-left: 15px;
}

.section-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 4px;
    background: linear-gradient(to bottom, #4f46e5, #7c3aed);
    border-radius: 2px;
}

/* 按钮点击效果 */
.btn:active {
    transform: scale(0.98);
}

/* 历史档案卡片悬停 */
.archive-card:hover {
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.2);
    border-color: #c7d2fe;
}
</style>
